<div class="page" id="search">
	<?php if($this->view->func == 'results') { ?>
		<h3><a href="search" data-to="ajax">Search</a> / <?php echo $this->view->query; ?></h3>
		<div class="highlight_words"><?php echo $this->view->list; ?></div>
		<table>
			<?php if(count($this->view->data) > 0) { ?>
				<tr>
					<td colspan="2">
						<form class="search_handlers">
							<div class="left"><button data-handle="refresh">Refresh</button></div>
							<div class="right">
								<?php echo $this->partial('helpers/pagination.php', array('url' => "search/results/{$this->view->id}", 'pagination' => $this->view->pagination)); ?>
								<div class="clear"></div>
							</div>
							<div class="clear"></div>
						</form>
					</td>
				</tr>
				<tr><td colspan="2" class="delimiter"></td></tr>
				<?php foreach($this->view->data as $idx => $one) { ?>
					<tr id="reply_<?php echo $one['id']; ?>">
						<td class="author">
							<?php echo $this->partial('helpers/avatar.php', array(
								'size' => 40,
								'user' => array(
									'id' => $one['author_id'],
									'link' => $one['author_link'],
									'name' => $one['author_name'],
									'avatar' => $one['author_avatar']
								)
							)); ?>
							<div class="clear"></div>
						</td>
						<td class="reply">
							<div class="meta">
								<h4><a data-to="ajax" href="profile/view/<?php echo $one['author_link']; ?>"><?php echo $one['author_name']; ?></a></h4>
								<span><?php echo $one['author_rank']; ?> <span class="bull">&bull;</span> Posted: <?php echo $this->partial('helpers/time.php', array('time' => $one['time'])); ?>
									<span class="bull">&bull;</span> <a href="javascript:void(0);" class="find_post" data-id="<?php echo $one['topic_id']; ?>" data-reply="<?php echo $one['id']; ?>"><?php echo $one['topic_name']; ?></a>
								</span>
							</div>
							<div class="msg"><?php echo $one['message']; ?></div>
						</td>
					</tr>
					<tr><td colspan="2" class="delimiter"></td></tr>
				<?php } ?>
				<tr>
					<td colspan="2">
						<form class="search_handlers">
							<div class="left"><button data-handle="refresh">Refresh</button></div>
							<div class="right">
								<?php echo $this->partial('helpers/pagination.php', array('url' => "search/results/{$this->view->id}", 'pagination' => $this->view->pagination)); ?>
								<div class="clear"></div>
							</div>
							<div class="clear"></div>
						</form>
					</td>
				</tr>
			<?php } else { ?>
				<tr><td>No results found.</td></tr>
			<?php } ?>
		</table>
	<?php } else { ?>
		<h3>Search</h3>
		<?php if(count($this->view->data) > 0) { ?>
			<span class="advice">Here is a list with the top 20 most used words:
				<div class="list">
					<?php foreach($this->view->data as $one) { ?>
						<a data-to="ajax" href="search/results/<?php echo $one['link']; ?>" title="<?php echo $one['hits'] . ($one['hits'] == 1 ? ' Hit' : ' Hits'); ?>"><?php echo $one['word']; ?></a>
					<?php } ?>
					<div class="clear"></div>
				</div>
			</span>
			<h4>Inquiry</h4>
			<form id="form_search">
				<label class="input">
					<input type="text" value="" name="query" maxlength="70">
					<span>Query</span>
				</label>
				<div class="right"><button type="submit">Submit</button></div>
				<div class="clear"></div>
			</form>
		<?php } else { ?>
			No words have been indexed yet.
		<?php } ?>
	<?php } ?>
</div>